package com.example.dao;

import com.example.domain.Training;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author luo
 */
@Mapper
public interface TrainingDao {
    /**
     * 查看培训信息
     * @return
     */
    @Select("select * from training")
    public List<Training> selectTrain();

    /**
     * 根据id查询培训信息
     * @param id
     * @return
     */
    @Select("select * from training where id=#{id};")
    public Training selectTrainById(Integer id);
    /**
     * 模糊查询
     * @param training
     * @return
     */
//    @Select("select * from training where name like #{name};")
    public List<Training> selectTrainByName(Training training);

    /**
     * 添加培训信息
     * @param training
     * @return
     */
    @Insert("insert into training (name,starttime,endtime, site, content, amount) values (#{name},#{starttime},#{endtime},#{site},#{content},#{amount});")
    public int addTrain(Training training);

    /**
     * 更新培训信息
     *
     * @param training
     * @return
     */
    @Update("update training set name=#{name}, starttime=#{starttime},endtime = #{endtime},site=#{site},content=#{content},amount=#{amount} where id=#{id};")
    public int updateTrain(Training training);

    /**
     * 根据id删除培训信息
     * @param id
     * @return
     */
    @Delete("delete from training where id=#{id};")
    public int deleteTrain(Integer id);
}
